﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using PowersourceUIToolkit;
using UCL.Powersource.Analysis;
using UCL.Powersource.ViewModels.Analysis;

namespace UCL.Powersource
{

    public class DummyReportingManager : InitializedLifeCycleBase, IReportingManager
    {
        //[ImportMany(typeof(IStatisticViewModel))]
        //private List<IStatisticViewModel> _StatisticViewModels;

        protected override bool OnInitializing()
        {
            StatisticViewModels = new System.Collections.ObjectModel.ReadOnlyCollection<IStatisticViewModel>(new List<IStatisticViewModel>());
            //if (_StatisticViewModels == null)
            //{
            //    var r= IoC.GetAllInstances(typeof(IStatisticViewModel));
            //    _StatisticViewModels = r.Cast<IStatisticViewModel>().ToList();
            //}
            //Log.Debug("Imported IStatisticViewModel:");
            //if (_StatisticViewModels != null && _StatisticViewModels.Count > 0)
            //{
            //    foreach (var it in _StatisticViewModels)
            //    {
            //        Log.Debug("{0} from {1}", it.GetType().FullName, it.GetType().AssemblyQualifiedName);
            //    }
            //    StatisticViewModels = new System.Collections.ObjectModel.ReadOnlyCollection<IStatisticViewModel>(_StatisticViewModels);
            //}
            //else
            //{
            //    Log.Warn("No statistic view found! Reporting will be empty!");
            //    StatisticViewModels = new System.Collections.ObjectModel.ReadOnlyCollection<IStatisticViewModel>(new List<IStatisticViewModel>());
            //}
            return true;
        }

        protected override void OnDisposing()
        {
        }

        public System.Collections.ObjectModel.ReadOnlyCollection<IStatisticViewModel> StatisticViewModels
        {
            get;
            private set;
        }


        public IEnumerable<Analysis.IStatistic> GetRegisteredStatistics(IStatisticViewModel ivm)
        {
            return new List<IStatistic>();
        }

        public void RegisterStatistics(IStatisticViewModel it)
        {
            return;
        }

        public void RegisterStatistics()
        {
            return;
        }


        private List<IReportingContextStrategy> _Strategies = new List<IReportingContextStrategy>() { new Default_ReportingContextStrategy(), new AllSelected_ReportingContextStrategy() };

        public System.Collections.ObjectModel.ReadOnlyCollection<IReportingContextStrategy> _ReportingContextStrategies;
        public System.Collections.ObjectModel.ReadOnlyCollection<IReportingContextStrategy> ReportingContextStrategies
        {
            get { return _ReportingContextStrategies ?? (_ReportingContextStrategies = new System.Collections.ObjectModel.ReadOnlyCollection<IReportingContextStrategy>(_Strategies)); }
        }
    }
}
